<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>显示购物车</title>
	<style type="text/css">
		table
		{
			border-collapse: collapse;
			text-align: center;
			table-layout: fixed;
			width: 700px;
		}
		table td, table th
		{
			border: 1px solid #cad9ea;
			color: #666;
			height: 30px;
		}
		table thead th
		{
			background-color: #CCE8EB;
			width: 100px;
		}
		table tr:nth-child(odd)
		{
			background: #fff;
		}
		table tr:nth-child(even)
		{
			background: #F5FAFA;
		}

		a{
			text-decoration: none;
		}
	</style>
</head>
<body>
 <h1 align="center">购物车列表</h1>
 <div align="center">
   <c:if test="${empty(cart.map) }">
	   <a href="index.jsp" style="font-size: 40px">点我返回上一层</a>
        <p style="font-size: 40px;color: red">您还没买任何商品</p>
   </c:if></div>
   <c:if test="${!empty(cart.map) }"> 
       <table border="3" align="center">
       	 <tr style="font-weight: bolder">
       	     <td>商品名称</td>
       	     <td>商品描述</td>
       	     <td>单价</td>
       	     <td>数量</td>
       	     <td>小计</td>
       	     <td>操作</td>
       	 </tr>
       	  <c:forEach items="${cart.map}" var="entry">
       	  <tr>
       	  	  <td>${entry.value.product.name}</td>
       	      <td>${entry.value.product.description}</td>
       	     <td>${entry.value.product.price}</td>
       	     <td>
				 <span><a href="CartAddCountServlet?id=${entry.value.product.id}" style="color: red">+</a></span>
					 ${entry.value.count}
				 <span><a href="CartDownCountServlet?id=${entry.value.product.id}" style="color: red">-</a></span>
			 </td>
       	     <td>${entry.value.price}</td>
       	     <td><a href="CartItemDeleteServlet?id=${entry.value.product.id}" style="color: red">删除</a></td>
       	  </tr> 
       	  </c:forEach>
       	  
       	  <tr>
			  <td><a href="index.jsp">返回上一页</a></td>
       	  	  <td colspan="2" style="font-weight: bolder">总价</td>
       	     <td colspan="2">${cart.price}</td>
       	     <td colspan="1"><a href="CartItemClearServlet">清空购物车</a></td>
       	  
       	  </tr>
       
       </table>
   </c:if>
</body>
</html>